import { defineStore } from 'pinia';
import ResourceAPI, { FileNode, FolderNode } from '@/service/resource';

export default defineStore('resource', {
  state: () => {
    return {
      entries: [] as Array<FileNode | FolderNode>
    }
  },

  actions: {
    async listChildren(path: string) {
      try {
        this.entries = await ResourceAPI.listChildren(path);
      } catch (e) {
        console.error(e);
      }
    }
  }
})